package leetcode.offer;

import leetcode.base.ListNode;

import java.util.Stack;

/**
 * ClassName: ReverseListPrint
 * Description:
 * date: 2021-10-28 20:31
 *
 * @author liyifan
 */
public class ReverseListPrint {
    public int[] reversePrint(ListNode head) {
        Stack<Integer> s = new Stack<>();
        ListNode p = head;
        while (p != null) {
            s.push(p.val);
            p = p.next;
        }
        int[] res = new int[s.size()];
        for (int i = 0;i < res.length;i++) {
            res[i] = s.pop();
        }
        return res;
    }
}
